#include "stdafx.h"
#include "Brick.h"

#include "GameScene.h"
#include "PhysicsSystem.h"

#include "PhysicsPrimitives.h"

void brickInit( Brick & brk, mphys::PhysicsSystem & physSys )
{
	brk.RigidBody = (mphys::Box*)&physSys.createBoxRigidBody();
}

void brickReset( Brick & brk, XMFLOAT3 pos, XMFLOAT4 orient, XMFLOAT3 scale )
{
	brk.Position = pos;
	brk.Orientation = orient;
	brk.Scale = scale;

	brk.BSphereRadius = (std::max)((std::max)(scale.x, scale.y), scale.z) * 29;

	mphys::RigidBodyDesc boxDesc;
	boxDesc.Position = pos;
	boxDesc.Orientation = orient;
	boxDesc.Scale = scale;
	boxDesc.IsStatic = true;
	boxDesc.Density = 0.5f;
	brk.RigidBody->reset(boxDesc);
}

void brickDestroy( Brick & brk, mphys::PhysicsSystem & physSys )
{
	physSys.removeRigidBody(*brk.RigidBody);
}
